package com.ljx.blog.security.common;

import com.ljx.blog.user.domain.dto.UserDto;

/**
 * @Author: LiJunXi
 * @Description:
 * @Date: 2024-10-04  00:09
 */
public class UserContext {

    private static ThreadLocal<UserDto> threadLocal = new ThreadLocal<>();
    private static ThreadLocal<Long> tenantThreadLocal = new ThreadLocal<>();

    public static UserDto getUser(){
        return threadLocal.get();
    }

    public static void setUser(UserDto userDto){
        threadLocal.set(userDto);
    }

    public static void removeUser(){
        threadLocal.remove();
    }


    public static Long getTenantId(){
        return tenantThreadLocal.get();
    }

    public static void setTenantId(Long tenantId){
        tenantThreadLocal.set(tenantId);
    }

    public static void removeTenant(){
        tenantThreadLocal.remove();
    }

}
